package com.school.controller;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class PagerInfo<T>  implements Serializable{

	private static final long serialVersionUID = 1L;
	// 当前页的数量
	private Integer size;
	private Integer currentPage;
	private Integer pageSize;
	private Integer total;
	private List<T> list;
	private Integer pages;

	public PagerInfo(PagerInfo esPager) {
		this.size=esPager.getSize();
		this.currentPage=esPager.getCurrentPage();
		this.pageSize=esPager.getPageSize();
		this.total=esPager.getTotal();
		this.pages=esPager.getPages();
		this.list=new ArrayList();
	}
	/**
	 * 只接受前4个必要的属性，会自动的计算出其他3个属性的值
	 *
	 * @param pageNum
	 * @param pageSize
	 * @param total
	 * @param list
	 */
	public PagerInfo(Integer currentPage, Integer pageSize, Integer total, List<T> list) {
		this.currentPage = currentPage;
		this.pageSize = pageSize;
		this.total = total;
		this.list = list;
		this.size = list==null ? 0 : list.size();
		// 计算总页码
		pages = pageSize == 0 ? 0 : (total + pageSize - 1) / pageSize;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public Integer getPages() {
		return pages;
	}

	public void setPages(Integer pages) {
		this.pages = pages;
	}

	public List<T> getList() {
		return list;
	}

	public void setList(List<T> list) {
		this.list = list;
	}

	public int getSize() {
		return size;
	}

	public void setSize(int size) {
		this.size = size;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public void setPageNum(int currentPage) {
		this.currentPage = currentPage;
	}

	public Integer getTotal() {
		return total;
	}

	public void setTotal(Integer total) {
		this.total = total;
	}

}
